﻿/*
版权所有：版权所有(C) 2011，刘建新
文件编号：M01_Mypaydetail.cs
文件名称：Mypaydetail.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2011-11-20
作　　者：
内容摘要：表[MyPayDetail]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：Mypaydetail
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class Mypaydetail : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is Mypaydetail)
				{
					if (obj == this)
						return true;
					Mypaydetail castObj = (Mypaydetail)obj; 
					
					if (!this.m_Paydetailid.Equals(castObj.Paydetailid))
						return false;
						
					if (!this.m_Username.Equals(castObj.Username))
						return false;
						
					if (!this.m_Amount.Equals(castObj.Amount))
						return false;
						
					if (!this.m_Createdate.Equals(castObj.Createdate))
						return false;
						
					if (!this.m_Remark.Equals(castObj.Remark))
						return false;
						
					if (!this.m_Status.Equals(castObj.Status))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Paydetailid != null)
					{
						hash = hash ^ m_Paydetailid.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Username != null)
					{
						hash = hash ^ m_Username.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Amount != null)
					{
						hash = hash ^ m_Amount.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createdate != null)
					{
						hash = hash ^ m_Createdate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Remark != null)
					{
						hash = hash ^ m_Remark.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Status != null)
					{
						hash = hash ^ m_Status.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public Mypaydetail()
			{
				MarkNew();
			}						
			
			public Mypaydetail GetOldValue()
			{
				return OldValue as Mypaydetail;
			}
		
		#region Paydetailid属性
			private int m_Paydetailid = 0;
			/// <summary>
			/// 属性名称： Paydetailid
			/// 内容摘要： DB列名：PayDetailid[]
			///            DB类型：int
			/// </summary>
			public int Paydetailid
			{
				get
					{
						return m_Paydetailid;
					}
				set
					{
						if (m_Paydetailid as object == null || !m_Paydetailid.Equals(value))
						{
							m_Paydetailid = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Username属性
			private string m_Username = String.Empty;
			/// <summary>
			/// 属性名称： Username
			/// 内容摘要： DB列名：UserName[]
			///            DB类型：string
			/// </summary>
			public string Username
			{
				get
					{
						return m_Username;
					}
				set
					{
						if (m_Username as object == null || !m_Username.Equals(value))
						{
							m_Username = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Amount属性
			private double m_Amount = 0;
			/// <summary>
			/// 属性名称： Amount
			/// 内容摘要： DB列名：Amount[]
			///            DB类型：double
			/// </summary>
			public double Amount
			{
				get
					{
						return m_Amount;
					}
				set
					{
						if (m_Amount as object == null || !m_Amount.Equals(value))
						{
							m_Amount = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createdate属性
			private DateTime m_Createdate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： Createdate
			/// 内容摘要： DB列名：CreateDate[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime Createdate
			{
				get
					{
						return DateTime.Parse(m_Createdate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_Createdate as object == null || !m_Createdate.Equals(value))
						{
							m_Createdate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Remark属性
			private string m_Remark = String.Empty;
			/// <summary>
			/// 属性名称： Remark
			/// 内容摘要： DB列名：Remark[]
			///            DB类型：string
			/// </summary>
			public string Remark
			{
				get
					{
						return m_Remark;
					}
				set
					{
						if (m_Remark as object == null || !m_Remark.Equals(value))
						{
							m_Remark = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Status属性
			private int m_Status = 0;
			/// <summary>
			/// 属性名称： Status
			/// 内容摘要： DB列名：Status[]
			///            DB类型：int
			/// </summary>
			public int Status
			{
				get
					{
						return m_Status;
					}
				set
					{
						if (m_Status as object == null || !m_Status.Equals(value))
						{
							m_Status = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("PayDetailid",typeof(int)));
					dtResult.Columns.Add(new DataColumn("UserName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Amount",typeof(double)));
					dtResult.Columns.Add(new DataColumn("CreateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Remark",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Status",typeof(int)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Paydetailid",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Username",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Amount",typeof(double)));
					dtResult.Columns.Add(new DataColumn("Createdate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Remark",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Status",typeof(int)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["PayDetailid"] = this.Paydetailid;
					dr["UserName"] = this.Username;
					dr["Amount"] = this.Amount;
					dr["CreateDate"] = this.Createdate;
					dr["Remark"] = this.Remark;
					dr["Status"] = this.Status;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Paydetailid"] = this.Paydetailid;
					dr["Username"] = this.Username;
					dr["Amount"] = this.Amount;
					dr["Createdate"] = this.Createdate;
					dr["Remark"] = this.Remark;
					dr["Status"] = this.Status;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成Mypaydetail对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>Mypaydetail对象</returns>
			public static Mypaydetail Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				Mypaydetail obj = new Mypaydetail();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Paydetailid = (dr["PayDetailid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["PayDetailid"],typeof(int));
					obj.Username = (dr["UserName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["UserName"],typeof(string));
					obj.Amount = (dr["Amount"] == Convert.DBNull) ? 0  : (double)Convert.ChangeType(dr["Amount"],typeof(double));
					obj.Createdate = (dr["CreateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["CreateDate"],typeof(DateTime));
					obj.Remark = (dr["Remark"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Remark"],typeof(string));
					obj.Status = (dr["Status"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Status"],typeof(int));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Paydetailid = (dr["Paydetailid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Paydetailid"],typeof(int));
					obj.Username = (dr["Username"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Username"],typeof(string));
					obj.Amount = (dr["Amount"] == Convert.DBNull) ? 0  : (double)Convert.ChangeType(dr["Amount"],typeof(double));
					obj.Createdate = (dr["Createdate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Createdate"],typeof(DateTime));
					obj.Remark = (dr["Remark"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Remark"],typeof(string));
					obj.Status = (dr["Status"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Status"],typeof(int));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成Mypaydetail对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>Mypaydetail对象</returns>
			public static Mypaydetail Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的Mypaydetail对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>Mypaydetail对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的Mypaydetail对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>Mypaydetail对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的Mypaydetail对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Mypaydetail对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(Mypaydetail obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的Mypaydetail对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Mypaydetail对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			Mypaydetail old = this.OldValue as Mypaydetail;
			if (old != null)
			{
					this.Paydetailid = old.Paydetailid;
					this.Username = old.Username;
					this.Amount = old.Amount;
					this.Createdate = old.Createdate;
					this.Remark = old.Remark;
					this.Status = old.Status;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region Mypaydetail实体的内部Key类
			/// <summary>
			/// Mypaydetail实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Paydetailid;
				public int Paydetailid
				{
 					get 
					{ 
						 return m_Paydetailid; 
					}
					set 
					{ 
						m_Paydetailid = value;
					}
				}
		
				public Key(int pPaydetailid)
				{
					m_Paydetailid=pPaydetailid;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体Mypaydetail的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Paydetailid);				
			}
			
				
		#endregion
	}
}
